package com.baizhi.service.impl;

import com.baizhi.annolation.LogAnnotation;
import com.baizhi.dao.GuruDao;
import com.baizhi.entity.Guru;
import com.baizhi.service.GuruService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional

public class GuruServiceImpl implements GuruService {
    @Autowired
    private GuruDao guruDao;
    @Override
    @LogAnnotation(type = "上师模块",value="进行了全查分页")
    public Map select(Integer page, Integer limit) {
        Map map=new HashMap();
        Integer offset=(page-1)*limit;
        List<Guru> select = guruDao.select(offset, limit);
        int count = guruDao.count();
            map.put("msg","");
             map.put("code",0);
             map.put("data",select);
            map.put("count",count);
        return map;
    }

    @Override
    @LogAnnotation(type = "上师模块",value="删除操作")
    public void delete(Integer id) {
        guruDao.delete(id);
    }

    @Override
    @LogAnnotation(type = "上师模块",value="添加操作")
    public void insert(Guru guru) {
        guruDao.insert(guru);
    }

    @Override
    @LogAnnotation(type = "上师模块",value="修改数据")
    public void update(Guru guru) {
        guruDao.update(guru);
    }

    @Override
    @LogAnnotation(type = "上师模块",value="批量添加上师")
    public void insertMore(List<Guru> guruList) {
        guruDao.insertMore(guruList);
    }
}
